package com.yanqu.road.server.cmd.activity.douluodalu;

import com.yanqu.road.entity.activity.douluodalu.log.PatronsBlood;
import com.yanqu.road.logic.pb.DouLuoDaLuPb;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.activity.douluodalu.DouLuoDaLuProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.douluodalu.CrossDouLuoDaLuMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;


@Cmd(code = Protocol.C_DOU_LUO_DA_LU_ONE_KEY_FIGHT_SETTLE, desc = "一键挑战(自动打完剩余进度)结算")
public class CrossDouLuoDaLuOneKeyFightSettleCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        DouLuoDaLuProto.DouLuoDaLuAutoBattleSettleReqMsg reqMsg = DouLuoDaLuProto.DouLuoDaLuAutoBattleSettleReqMsg.parseFrom(packet.getBytes());

        List<PatronsBlood> battleEnemyList = new ArrayList<>();
        for (DouLuoDaLuProto.DouLuoDaLuBattlePatronsBlood patronsBlood : reqMsg.getPatronsList()) {
            battleEnemyList.add(DouLuoDaLuPb.parseDouLuoDaLuPatronsBlood(patronsBlood));
        }
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.S_DOU_LUO_DA_LU_ONE_KEY_FIGHT_SETTLE_FROM_CROSS,
                CrossDouLuoDaLuMgr.oneKeyBattleSettle(reqMsg.getActivityId(), packet.getPlayerId(), reqMsg.getThisTime(), reqMsg.getWin(), reqMsg.getPatronsId(),
                        reqMsg.getPatronsNum(), reqMsg.getWinRewardsList(), reqMsg.getPatronsExp(), reqMsg.hasConsume() ? reqMsg.getConsume() : "", battleEnemyList, reqMsg.getBuffList(), reqMsg.getStartBuyIdxList())));

    }

    @Override
    public void sendData() {

    }
}
